package com.itheima.result;

/**
 * @projectName: kafka
 * @package: com.itheima.result
 * @className: BaseContext
 * @author: Eric
 * @description: TODO
 * @date: 2023/9/21 10:40
 * @version: 1.0
 */
public class BaseContext {

    private final static ThreadLocal<String> THREAD_LOCAL = new ThreadLocal<>();

    /**
     * 设置登录用户id
     *
     * @param userId 用户id
     */
    public static void setLoginUserId(String userId) {
        THREAD_LOCAL.set(userId);
    }

    /**
     * 获得登录用户id
     *
     * @return {@link String}
     */
    public static String getLoginUserId() {
        return THREAD_LOCAL.get();
    }

    /**
     * 删除登录用户id
     */
    public static void removeLoginUserId() {
        THREAD_LOCAL.remove();
    }

}
